<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    
    <title>GSettings | jouyouyun&#39;s blog</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1">
    <meta name="description" content="GSettings 实际上是一套可使用多个 storage backends 的 API ，默认使用 dconf 作为 backend ，也可以使用 keyfile 作为 backend 。但由于 gio 提供了 GKeyFile 结构来处理 keyfile 文件，所以解析 keyfile 文件时很少通过 GSettings API ，在这里只介绍使用 dconf 作为 backend 的使用方法。">
    <meta name="generator" content="Hugo 0.105.0">
    
    
    
    
      <meta name="robots" content="noindex, nofollow">
    

    
<link rel="stylesheet" href="/ananke/css/main.min.css" >



    
    
    
      

    

    
    
    <meta property="og:title" content="GSettings" />
<meta property="og:description" content="GSettings 实际上是一套可使用多个 storage backends 的 API ，默认使用 dconf 作为 backend ，也可以使用 keyfile 作为 backend 。但由于 gio 提供了 GKeyFile 结构来处理 keyfile 文件，所以解析 keyfile 文件时很少通过 GSettings API ，在这里只介绍使用 dconf 作为 backend 的使用方法。" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://jouyouyun.github.io/post/gsettings/" /><meta property="article:section" content="post" />
<meta property="article:published_time" content="2019-08-03T19:30:21+08:00" />
<meta property="article:modified_time" content="2019-08-04T21:03:16+08:00" />

<meta itemprop="name" content="GSettings">
<meta itemprop="description" content="GSettings 实际上是一套可使用多个 storage backends 的 API ，默认使用 dconf 作为 backend ，也可以使用 keyfile 作为 backend 。但由于 gio 提供了 GKeyFile 结构来处理 keyfile 文件，所以解析 keyfile 文件时很少通过 GSettings API ，在这里只介绍使用 dconf 作为 backend 的使用方法。"><meta itemprop="datePublished" content="2019-08-03T19:30:21+08:00" />
<meta itemprop="dateModified" content="2019-08-04T21:03:16+08:00" />
<meta itemprop="wordCount" content="908">
<meta itemprop="keywords" content="gsettings," /><meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="GSettings"/>
<meta name="twitter:description" content="GSettings 实际上是一套可使用多个 storage backends 的 API ，默认使用 dconf 作为 backend ，也可以使用 keyfile 作为 backend 。但由于 gio 提供了 GKeyFile 结构来处理 keyfile 文件，所以解析 keyfile 文件时很少通过 GSettings API ，在这里只介绍使用 dconf 作为 backend 的使用方法。"/>

	
  </head>

  <body class="ma0 avenir bg-near-white">

    
   
  

  <header>
    <div class="bg-black">
      <nav class="pv3 ph3 ph4-ns" role="navigation">
  <div class="flex-l justify-between items-center center">
    <a href="/" class="f3 fw2 hover-white no-underline white-90 dib">
      
        jouyouyun&#39;s blog
      
    </a>
    <div class="flex-l items-center">
      

      
        <ul class="pl0 mr3">
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/post/" title="Archives 页">
              Archives
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/tags/" title="Tags 页">
              Tags
            </a>
          </li>
          
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="/categories/" title="Categories 页">
              Categories
            </a>
          </li>
          
        </ul>
      
      
<div class="ananke-socials">
  
    <a href="https://github.com/jouyouyun" target="_blank" class="github ananke-social-link link-transition stackoverflow link dib z-999 pt3 pt0-l mr1" title="GitHub link" rel="noopener" aria-label="follow on GitHub——Opens in a new window">
      
        <span class="icon"><svg style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
  <path d="M256,32C132.3,32,32,134.8,32,261.7c0,101.5,64.2,187.5,153.2,217.9c11.2,2.1,15.3-5,15.3-11.1   c0-5.5-0.2-19.9-0.3-39.1c-62.3,13.9-75.5-30.8-75.5-30.8c-10.2-26.5-24.9-33.6-24.9-33.6c-20.3-14.3,1.5-14,1.5-14   c22.5,1.6,34.3,23.7,34.3,23.7c20,35.1,52.4,25,65.2,19.1c2-14.8,7.8-25,14.2-30.7c-49.7-5.8-102-25.5-102-113.5   c0-25.1,8.7-45.6,23-61.6c-2.3-5.8-10-29.2,2.2-60.8c0,0,18.8-6.2,61.6,23.5c17.9-5.1,37-7.6,56.1-7.7c19,0.1,38.2,2.6,56.1,7.7   c42.8-29.7,61.5-23.5,61.5-23.5c12.2,31.6,4.5,55,2.2,60.8c14.3,16.1,23,36.6,23,61.6c0,88.2-52.4,107.6-102.3,113.3   c8,7.1,15.2,21.1,15.2,42.5c0,30.7-0.3,55.5-0.3,63c0,6.1,4,13.3,15.4,11C415.9,449.1,480,363.1,480,261.7   C480,134.8,379.7,32,256,32z"/>
</svg>
</span>
      
<span class="new-window"><svg  height="8px"  style="enable-background:new 0 0 1000 1000;" version="1.1" viewBox="0 0 1000 1000"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
<path d="M598 128h298v298h-86v-152l-418 418-60-60 418-418h-152v-86zM810 810v-298h86v298c0 46-40 86-86 86h-596c-48 0-86-40-86-86v-596c0-46 38-86 86-86h298v86h-298v596h596z" style="fill-rule:evenodd;clip-rule:evenodd;"/>
</svg>
</span></a>
  
</div>

    </div>
  </div>
</nav>

    </div>
  </header>



    <main class="pb7" role="main">
      
  
  <article class="flex-l flex-wrap justify-between mw8 center ph3">
    <header class="mt4 w-100">
      <aside class="instapaper_ignoref b helvetica tracked">
          
        POSTS
      </aside>
      










  <div id="sharing" class="mt3 ananke-socials">
    
  </div>


      <h1 class="f1 athelas mt3 mb1">GSettings</h1>
      
      <p class="tracked">
         <strong>jouyouyun</strong>
      </p>
      
      
      
      <time class="f6 mv4 dib tracked" datetime="2019-08-03T19:30:21+08:00">八月 3, 2019</time>
      

      
      
    </header>
    <div class="nested-copy-line-height lh-copy serif f4 nested-links mid-gray pr4-l w-two-thirds-l"><p><code>GSettings</code> 实际上是一套可使用多个 <code>storage backends</code> 的 <code>API</code> ，默认使用 <code>dconf</code> 作为 <code>backend</code> ，也可以使用 <code>keyfile</code> 作为 <code>backend</code> 。但由于 <code>gio</code> 提供了 <code>GKeyFile</code> 结构来处理 <code>keyfile</code> 文件，所以解析 <code>keyfile</code> 文件时很少通过 <code>GSettings API</code> ，在这里只介绍使用 <code>dconf</code> 作为 <code>backend</code> 的使用方法。</p>
<hr>
<h2 id="dconf">dconf</h2>
<p><code>dconf</code> 是一个底层的配置管理系统，被设计用来作为 <code>GSettings</code> 的 <code>backend</code> ，并提供了图形化的配置管理工具 <code>dconf-editor</code> ，具有以下特点：</p>
<ul>
<li>
<p>检索快速</p>
<p><code>dconf</code> 使用 <code>gvdb(GVariant Database file)</code> 格式的二进制文件存储数据，它是一个简单的数据库，以路径映射的方式存储 <code>key</code> ，检索高效。默认的文件路径为： <code>~/.config/dconf/user</code></p>
</li>
<li>
<p>支持改变通知</p>
<p><code>dconf</code> 支持在 <code>key</code> 发生改变时发出通知</p>
</li>
</ul>
<hr>
<h2 id="配置文件">配置文件</h2>
<p><code>GSettings</code> 的配置文件是 <code>xml</code> 格式的，文件需以 <code>.gschema.xml</code> 结尾，文件名通常与 <code>id</code> 相同。配置文件安装在 <code>/usr/share/glib-2.0/schemas/</code> 目录下，手动添加进去的文件需要执行 <code>sudo glib-complie-schemas /usr/share/glib-2.0/schemas</code> 让其生效。</p>
<p>文件内容简要格式如下：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;schemalist&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;schema</span> <span style="color:#a6e22e">path=</span><span style="color:#e6db74">&#34;&#34;</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;&#34;</span>  <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/schema&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/schemalist&gt;</span>
</span></span></code></pre></div><p>可以看到一个文件里可以包含多个 <code>schema</code> ，每个 <code>schema</code> 可由多个 <code>key</code> 组成。详细说明如下：</p>
<ul>
<li>
<p>id</p>
<p><code>schema</code> 中的 <code>id</code> 需要在整个配置系统中是唯一的，不然执行 <code>glib-compile-schemas</code> 时会忽略重复的 <code>id</code> ； <code>id</code> 的开头通常使用与应用相关的域名</p>
</li>
<li>
<p>path</p>
<p><code>schema</code> 中的 <code>path</code> 必须是以 <code>/</code> 开头并且以 <code>/</code> 结尾，不能包含连续的 <code>/</code> , <code>path</code> 用于指定在 <code>storage</code> 中存储路径，可以与 <code>id</code> 不一致</p>
</li>
<li>
<p>name</p>
<p><code>key</code> 的名称，需要在此 <code>schema</code> 中是唯一的， <code>name</code> 的值由小写字母、数字和 <code>-</code> 组成，并且开头必须是小写字母，不能以 <code>-</code> 结尾，也不能出现连续的 <code>-</code></p>
</li>
<li>
<p>type</p>
<p><code>key</code> 的类型，需要是 <code>GVariant</code> 支持的类型，除了可以使用基本的类型外，也可按照 <code>GVariant</code> 的方式组合类型</p>
</li>
<li>
<p>default</p>
<p><code>key</code> 的默认值</p>
</li>
<li>
<p>summary</p>
<p><code>key</code> 的简单描述</p>
</li>
<li>
<p>description</p>
<p><code>key</code> 的详细描述</p>
</li>
</ul>
<hr>
<p>下面给出一个例子：</p>
<p><code>schema</code> 文件：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;schemalist&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;enum</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;com.deepin.test.LogLevel&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;value</span> <span style="color:#a6e22e">nick=</span><span style="color:#e6db74">&#34;debug&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;1&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;value</span> <span style="color:#a6e22e">nick=</span><span style="color:#e6db74">&#34;info&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;2&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;value</span> <span style="color:#a6e22e">nick=</span><span style="color:#e6db74">&#34;fatal&#34;</span> <span style="color:#a6e22e">value=</span><span style="color:#e6db74">&#34;3&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/enum&gt;</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;schema</span> <span style="color:#a6e22e">path=</span><span style="color:#e6db74">&#34;/com/deepin/test/&#34;</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;com.deepin.test&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;b&#34;</span>  <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;enabled&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>true<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Enable this module.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Whether enable this module.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">enum=</span><span style="color:#e6db74">&#34;com.deepin.test.LogLevel&#34;</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;loglevel&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>&#39;info&#39;<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Log level.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Log level.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;i&#34;</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;interval&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>10<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;range</span> <span style="color:#a6e22e">min=</span><span style="color:#e6db74">&#34;0&#34;</span> <span style="color:#a6e22e">max=</span><span style="color:#e6db74">&#34;60&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Timer duration.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Timer duration.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;(ii)&#34;</span> <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;size&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>(800,600)<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>The window size.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>The window size.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/schema&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/schemalist&gt;</span>
</span></span></code></pre></div><p>程序代码如下：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-c" data-lang="c"><span style="display:flex;"><span><span style="color:#75715e">/**
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * Copyright (C) 2019 jouyouyun &lt;jouyouwen717@gmail.com&gt;
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * This program is free software; you can redistribute it and/or modify
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * it under the terms of the GNU General Public License as published by
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * the Free Software Foundation; either version 3 of the License, or
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * (at your option) any later version.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * example.c -- An example for gsettings.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * compile:
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *    gcc -Wall -g example.c `pkg-config --libs --cflags gio-2.0`
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> */</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#include</span> <span style="color:#75715e">&lt;gio/gio.h&gt;</span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">int</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">main</span>(<span style="color:#66d9ef">int</span> argc, <span style="color:#66d9ef">char</span> <span style="color:#f92672">*</span>argv[])
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    GSettings <span style="color:#f92672">*</span>gs;
</span></span><span style="display:flex;"><span>    gboolean enabled;
</span></span><span style="display:flex;"><span>    gint loglevel, interval, width, height;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#75715e">// if failed, will segmetfault
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>    gs <span style="color:#f92672">=</span> g_settings_new(<span style="color:#e6db74">&#34;com.deepin.test&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    enabled <span style="color:#f92672">=</span> g_settings_get_boolean(gs, <span style="color:#e6db74">&#34;enabled&#34;</span>);
</span></span><span style="display:flex;"><span>    g_print(<span style="color:#e6db74">&#34;Enabled: %d</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, enabled);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    loglevel <span style="color:#f92672">=</span> g_settings_get_enum(gs, <span style="color:#e6db74">&#34;loglevel&#34;</span>);
</span></span><span style="display:flex;"><span>    g_print(<span style="color:#e6db74">&#34;Log level: %d</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, loglevel);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    interval <span style="color:#f92672">=</span> g_settings_get_int(gs, <span style="color:#e6db74">&#34;interval&#34;</span>);
</span></span><span style="display:flex;"><span>    g_print(<span style="color:#e6db74">&#34;Timer duration: %d</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, interval);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    g_settings_get(gs, <span style="color:#e6db74">&#34;size&#34;</span>, <span style="color:#e6db74">&#34;(ii)&#34;</span>, <span style="color:#f92672">&amp;</span>width, <span style="color:#f92672">&amp;</span>height);
</span></span><span style="display:flex;"><span>    g_print(<span style="color:#e6db74">&#34;Width: %d, height: %d</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, width, height);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    g_object_unref(gs);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><p><strong>注意：</strong> 在使用接口调用时，需要确保 <code>schema</code> 和 <code>key</code> 存在，不然会触发 <strong>段错误</strong> 。</p>
<hr>
<h3 id="relocatable-schema"><code>Relocatable Schema</code></h3>
<p>通常一个 <code>id</code> 对应一个固定的 <code>path</code> ，但也可以没有，即不设置 <code>path</code> ，这样就是一个可重定位的 <code>schema</code> 。这个特性对于可变的配置很有用，如用户自定义的快捷键：快捷键的个数是不可知，这时可利用这个特性先声明一个快捷键 <code>schema</code> 作为模板，然后动态创建多个 <code>path</code> 来使用。示例如下：</p>
<p><code>schema</code> 文件如下：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;schemalist&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;schema</span> <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;com.deepin.test.keybind&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;s&#34;</span>  <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;name&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>&#39;&#39;<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Shortcut name.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Shortcut name.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;as&#34;</span>  <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;shortcuts&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>[&#39;&#39;]<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Shortcut keys.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Shortcut keys.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;s&#34;</span>  <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;action&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>&#39;&#39;<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Shortcut action.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Shortcut action.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;key</span> <span style="color:#a6e22e">type=</span><span style="color:#e6db74">&#34;s&#34;</span>  <span style="color:#a6e22e">name=</span><span style="color:#e6db74">&#34;description&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;default&gt;</span>&#39;&#39;<span style="color:#f92672">&lt;/default&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;summary&gt;</span>Shortcut description.<span style="color:#f92672">&lt;/summary&gt;</span>
</span></span><span style="display:flex;"><span>            <span style="color:#f92672">&lt;description&gt;</span>Shortcut description.<span style="color:#f92672">&lt;/description&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;/key&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/schema&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/schemalist&gt;</span>
</span></span></code></pre></div><p>程序代码如下：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-c" data-lang="c"><span style="display:flex;"><span><span style="color:#75715e">/**
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * Copyright (C) 2019 jouyouyun &lt;jouyouwen717@gmail.com&gt;
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * This program is free software; you can redistribute it and/or modify
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * it under the terms of the GNU General Public License as published by
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * the Free Software Foundation; either version 3 of the License, or
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * (at your option) any later version.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * relocatable.c -- An example for gsettings relocatable path.
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> * compile:
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> *    gcc -Wall -g relocatable.c `pkg-config --libs --cflags gio-2.0`
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"> */</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">#include</span> <span style="color:#75715e">&lt;stdio.h&gt;</span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e">#include</span> <span style="color:#75715e">&lt;gio/gio.h&gt;</span><span style="color:#75715e">
</span></span></span><span style="display:flex;"><span><span style="color:#75715e"></span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">static</span> <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">set_keybind</span>(GSettings <span style="color:#f92672">*</span>gs);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">static</span> <span style="color:#66d9ef">void</span> <span style="color:#a6e22e">get_keybind</span>(GSettings <span style="color:#f92672">*</span>gs);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">static</span> <span style="color:#66d9ef">void</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">set_keybind</span>(GSettings <span style="color:#f92672">*</span>gs)
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    gboolean ok;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    ok <span style="color:#f92672">=</span> g_settings_set_string(gs, <span style="color:#e6db74">&#34;name&#34;</span>, <span style="color:#e6db74">&#34;test&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>ok) {
</span></span><span style="display:flex;"><span>        g_warning(<span style="color:#e6db74">&#34;Failed to set name to &#39;test&#39;&#34;</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">const</span> gchar <span style="color:#f92672">*</span>shortcuts[] <span style="color:#f92672">=</span> {<span style="color:#e6db74">&#34;Control-Alt-T&#34;</span>, <span style="color:#e6db74">&#34;Super-T&#34;</span>, NULL};
</span></span><span style="display:flex;"><span>    ok <span style="color:#f92672">=</span> g_settings_set_strv(gs, <span style="color:#e6db74">&#34;shortcuts&#34;</span>, shortcuts);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>ok) {
</span></span><span style="display:flex;"><span>        g_warning(<span style="color:#e6db74">&#34;Failed to set shortcuts&#34;</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>    ok <span style="color:#f92672">=</span> g_settings_set_string(gs, <span style="color:#e6db74">&#34;action&#34;</span>, <span style="color:#e6db74">&#34;terminator&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>ok) {
</span></span><span style="display:flex;"><span>        g_warning(<span style="color:#e6db74">&#34;Failed to set action to &#39;terminator&#39;&#34;</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>    ok <span style="color:#f92672">=</span> g_settings_set_string(gs, <span style="color:#e6db74">&#34;description&#34;</span>, <span style="color:#e6db74">&#34;the shortcuts for terminator&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (<span style="color:#f92672">!</span>ok) {
</span></span><span style="display:flex;"><span>        g_warning(<span style="color:#e6db74">&#34;Failed to set description to &#39;the shortcuts for terminator&#39;&#34;</span>);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">static</span> <span style="color:#66d9ef">void</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">get_keybind</span>(GSettings <span style="color:#f92672">*</span>gs)
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    gchar <span style="color:#f92672">*</span>name, <span style="color:#f92672">*</span>action, <span style="color:#f92672">*</span>desc;
</span></span><span style="display:flex;"><span>    gchar <span style="color:#f92672">**</span>shortcuts <span style="color:#f92672">=</span> NULL;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    name <span style="color:#f92672">=</span> g_settings_get_string(gs, <span style="color:#e6db74">&#34;name&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (name) {
</span></span><span style="display:flex;"><span>        g_print(<span style="color:#e6db74">&#34;Shortcut name: %s</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, name);
</span></span><span style="display:flex;"><span>        g_free(name);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    shortcuts <span style="color:#f92672">=</span> g_settings_get_strv(gs, <span style="color:#e6db74">&#34;shortcuts&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (shortcuts) {
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">int</span> i <span style="color:#f92672">=</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>        g_print(<span style="color:#e6db74">&#34;Shortcut key: &#34;</span>);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">for</span> (; shortcuts[i]; i<span style="color:#f92672">++</span>) {
</span></span><span style="display:flex;"><span>            <span style="color:#66d9ef">if</span> (i <span style="color:#f92672">!=</span> <span style="color:#ae81ff">0</span>) {
</span></span><span style="display:flex;"><span>                g_print(<span style="color:#e6db74">&#34;, &#34;</span>);
</span></span><span style="display:flex;"><span>            }
</span></span><span style="display:flex;"><span>            g_print(<span style="color:#e6db74">&#34;%s&#34;</span>, shortcuts[i]);
</span></span><span style="display:flex;"><span>            g_free(shortcuts[i]);
</span></span><span style="display:flex;"><span>        }
</span></span><span style="display:flex;"><span>        g_print(<span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>);
</span></span><span style="display:flex;"><span>        g_free(shortcuts);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    action <span style="color:#f92672">=</span> g_settings_get_string(gs, <span style="color:#e6db74">&#34;action&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (action) {
</span></span><span style="display:flex;"><span>        g_print(<span style="color:#e6db74">&#34;Shortcut action: %s</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, action);
</span></span><span style="display:flex;"><span>        g_free(action);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    desc <span style="color:#f92672">=</span> g_settings_get_string(gs, <span style="color:#e6db74">&#34;description&#34;</span>);
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (desc) {
</span></span><span style="display:flex;"><span>        g_print(<span style="color:#e6db74">&#34;Shortcut desc: %s</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, desc);
</span></span><span style="display:flex;"><span>        g_free(desc);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">int</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">main</span>(<span style="color:#66d9ef">int</span> argc, <span style="color:#66d9ef">char</span> <span style="color:#f92672">*</span>argv[])
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (argc <span style="color:#f92672">!=</span> <span style="color:#ae81ff">3</span>) {
</span></span><span style="display:flex;"><span>        g_print(<span style="color:#e6db74">&#34;Usage: %s &lt;action&gt; &lt;keybind id&gt;</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\t</span><span style="color:#e6db74">action: get or set</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>
</span></span><span style="display:flex;"><span>                <span style="color:#e6db74">&#34;</span><span style="color:#ae81ff">\t</span><span style="color:#e6db74">keybind id: a non-negative integer</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, argv[<span style="color:#ae81ff">0</span>]);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    GSettings <span style="color:#f92672">*</span>gs;
</span></span><span style="display:flex;"><span>    gchar buf[<span style="color:#ae81ff">1024</span>] <span style="color:#f92672">=</span> {<span style="color:#ae81ff">0</span>};
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (sprintf(buf, <span style="color:#e6db74">&#34;/com/deepin/test/keybind/%s/&#34;</span>, argv[<span style="color:#ae81ff">2</span>]) <span style="color:#f92672">&lt;</span> <span style="color:#ae81ff">0</span>) {
</span></span><span style="display:flex;"><span>        g_error(<span style="color:#e6db74">&#34;Failed to combains path: %s</span><span style="color:#ae81ff">\n</span><span style="color:#e6db74">&#34;</span>, argv[<span style="color:#ae81ff">2</span>]);
</span></span><span style="display:flex;"><span>        <span style="color:#66d9ef">return</span> <span style="color:#f92672">-</span><span style="color:#ae81ff">1</span>;
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>    gs <span style="color:#f92672">=</span> g_settings_new_with_path(<span style="color:#e6db74">&#34;com.deepin.test.keybind&#34;</span>, buf);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">if</span> (g_strcmp0(argv[<span style="color:#ae81ff">1</span>], <span style="color:#e6db74">&#34;set&#34;</span>) <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>) {
</span></span><span style="display:flex;"><span>        set_keybind(gs);
</span></span><span style="display:flex;"><span>    } <span style="color:#66d9ef">else</span> <span style="color:#66d9ef">if</span> (g_strcmp0(argv[<span style="color:#ae81ff">1</span>], <span style="color:#e6db74">&#34;get&#34;</span>) <span style="color:#f92672">==</span> <span style="color:#ae81ff">0</span>) {
</span></span><span style="display:flex;"><span>        get_keybind(gs);
</span></span><span style="display:flex;"><span>    } <span style="color:#66d9ef">else</span> {
</span></span><span style="display:flex;"><span>        g_warning(<span style="color:#e6db74">&#34;invalid action: %s&#34;</span>, argv[<span style="color:#ae81ff">1</span>]);
</span></span><span style="display:flex;"><span>    }
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    g_object_unref(gs);
</span></span><span style="display:flex;"><span>    g_settings_sync();
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">return</span> <span style="color:#ae81ff">0</span>;
</span></span><span style="display:flex;"><span>}
</span></span></code></pre></div><hr>
<h3 id="override">override</h3>
<p><code>gsettings</code> 支持 <code>override</code> 机制，可以更改默认值。</p>
<p>通常 <code>key</code> 的默认值在文件中已经指定，但有时不同的版本上需要的默认值不同，这时 <code>override</code> 机制就很有用，可以在不修改配置文件的情况下更改默认值。</p>
<p><code>override</code> 文件以 <strong><code>数字_</code></strong> 开头，并以 <strong><code>.gschema.override</code></strong> 结尾，数字为两位整数，数值越大优先级越高。</p>
<p><code>override</code> 文件同样安装在 <code>/usr/share/glib-2.0/schemas</code> 目录下，并需要使用 <code>glib-compile-schemas</code> 编译。</p>
<p><code>override</code> 文件的格式如下：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ini" data-lang="ini"><span style="display:flex;"><span><span style="color:#66d9ef">[schema id]</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">key</span><span style="color:#f92672">=</span><span style="color:#e6db74">value</span>
</span></span></code></pre></div><p>如更改 <code>com.deepin.test</code> 中 <code>interval</code> 的默认值为 <code>30</code> ，则内容如下：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-ini" data-lang="ini"><span style="display:flex;"><span><span style="color:#66d9ef">[com.deepin.test]</span>
</span></span><span style="display:flex;"><span><span style="color:#a6e22e">interval</span><span style="color:#f92672">=</span><span style="color:#e6db74">30</span>
</span></span></code></pre></div><p>然后执行：</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-shell" data-lang="shell"><span style="display:flex;"><span>sudo cp ./90_com.deepin.test.gschema.override /usr/share/glib-2.0/schemas/
</span></span><span style="display:flex;"><span>sudo glib-compile-schemas /usr/share/glib-2.0/schemas
</span></span></code></pre></div><hr>
<h3 id="key-改变信号">key 改变信号</h3>
<p><code>GSettings</code> 提供了 <code>changed</code> 信号来发送 <code>key</code> 改变的事件，如有需要可监听此信号。</p>
<hr>
<h2 id="工具">工具</h2>
<h3 id="glib-sompile-schemas">glib-sompile-schemas</h3>
<p>编译 <code>schema</code> 文件的命令</p>
<h3 id="dconf-editor"><code>dconf-editor</code></h3>
<p><code>dconf</code> 的图形工具，根据 <code>path</code> 检索，可管理 <code>key</code></p>
<h3 id="devhelp">devhelp</h3>
<p>一款 <code>API</code> 文档查看工具，安装了 <code>libglib2.0-docs</code> 后，可在 <code>devhelp</code> 中查看 <code>GSettings</code> 的 <code>API</code> 文档</p>
<h3 id="gsettings">gsettings</h3>
<p>这是一个 <code>gsettings</code> 的配置管理工具，下面介绍一些常用的子命令，详细用法请查看 <code>man</code> 手册：</p>
<ul>
<li>
<p>list-schemas</p>
<p>列出所有已安装并有固定 <code>path</code> 的 <code>schema</code></p>
</li>
<li>
<p>list-relocatable-schemas</p>
<p>列出所有已安装却没有固定 <code>path</code> 的 <code>schema</code></p>
</li>
<li>
<p>list-keys</p>
<p>列出指定 <code>schema</code> 中的所有 <code>key</code></p>
</li>
<li>
<p>list-recursively</p>
<p>列出指定 <code>schema</code> 中的所有 <code>key</code> 及其 <code>value</code> ，若 <code>schema</code> 未指定，则列出所有 <code>schema</code> 的</p>
</li>
<li>
<p>get</p>
<p>获取指定 <code>schema</code> 中指定 <code>key</code> 的值</p>
</li>
<li>
<p>set</p>
<p>设置指定 <code>schema</code> 中指定 <code>key</code> 的值</p>
</li>
<li>
<p>reset</p>
<p>重置指定 <code>schema</code> 中指定 <code>key</code> 的值，即恢复默认值</p>
</li>
<li>
<p>monitor</p>
<p>监听指定 <code>schema</code> 中指定 <code>key</code> 的改变，不指定时监听所有的</p>
</li>
</ul>
<hr>
<h2 id="参考资料">参考资料</h2>
<ul>
<li><a href="https://en.wikipedia.org/wiki/Dconf">dconf</a></li>
<li><a href="https://developer.gnome.org/GSettings/">GSettings</a></li>
<li><a href="https://developer.gnome.org/gio/stable/GSettings.html">GSettings API</a></li>
<li><a href="https://developer.gnome.org/glib/stable/gvariant-format-strings.html">GVariant Format Strings</a></li>
</ul><ul class="pa0">
  
   <li class="list di">
     <a href="/tags/gsettings" class="link f5 grow no-underline br-pill ba ph3 pv2 mb2 dib black sans-serif">gsettings</a>
   </li>
  
</ul>
<div class="mt6 instapaper_ignoref">
      
      
      </div>
    </div>

    <aside class="w-30-l mt6-l">




</aside>

  </article>

    </main>
    <footer class="bg-black bottom-0 w-100 pa3" role="contentinfo">
  <div class="flex justify-between">
  <a class="f4 fw4 hover-white no-underline white-70 dn dib-ns pv2 ph3" href="https://jouyouyun.github.io" >
    &copy;  jouyouyun 2023 
  </a>
    <div>
<div class="ananke-socials">
  
    <a href="https://github.com/jouyouyun" target="_blank" class="github ananke-social-link link-transition stackoverflow link dib z-999 pt3 pt0-l mr1" title="GitHub link" rel="noopener" aria-label="follow on GitHub——Opens in a new window">
      
        <span class="icon"><svg style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
  <path d="M256,32C132.3,32,32,134.8,32,261.7c0,101.5,64.2,187.5,153.2,217.9c11.2,2.1,15.3-5,15.3-11.1   c0-5.5-0.2-19.9-0.3-39.1c-62.3,13.9-75.5-30.8-75.5-30.8c-10.2-26.5-24.9-33.6-24.9-33.6c-20.3-14.3,1.5-14,1.5-14   c22.5,1.6,34.3,23.7,34.3,23.7c20,35.1,52.4,25,65.2,19.1c2-14.8,7.8-25,14.2-30.7c-49.7-5.8-102-25.5-102-113.5   c0-25.1,8.7-45.6,23-61.6c-2.3-5.8-10-29.2,2.2-60.8c0,0,18.8-6.2,61.6,23.5c17.9-5.1,37-7.6,56.1-7.7c19,0.1,38.2,2.6,56.1,7.7   c42.8-29.7,61.5-23.5,61.5-23.5c12.2,31.6,4.5,55,2.2,60.8c14.3,16.1,23,36.6,23,61.6c0,88.2-52.4,107.6-102.3,113.3   c8,7.1,15.2,21.1,15.2,42.5c0,30.7-0.3,55.5-0.3,63c0,6.1,4,13.3,15.4,11C415.9,449.1,480,363.1,480,261.7   C480,134.8,379.7,32,256,32z"/>
</svg>
</span>
      
<span class="new-window"><svg  height="8px"  style="enable-background:new 0 0 1000 1000;" version="1.1" viewBox="0 0 1000 1000"  xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" >
<path d="M598 128h298v298h-86v-152l-418 418-60-60 418-418h-152v-86zM810 810v-298h86v298c0 46-40 86-86 86h-596c-48 0-86-40-86-86v-596c0-46 38-86 86-86h298v86h-298v596h596z" style="fill-rule:evenodd;clip-rule:evenodd;"/>
</svg>
</span></a>
  
</div>
</div>
  </div>
</footer>

  </body>
</html>
